//
//  ViewController.m
//  通知测试 dome
//
//  Created by 石虎 on 2017/7/22.
//  Copyright © 2017年 shihu. All rights reserved.
//

#import "ViewController.h"
#import "SHTwoViewController.h"

@interface ViewController ()

//显示传值的内容
@property (weak, nonatomic) IBOutlet UILabel *textStrng;
//跳转
- (IBAction)notificationClick:(UIButton *)sender;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    //注册通知----第一部
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(showLabelText:) name:@"labelTextNotification" object:nil];
}
//实现通知监听 ---第二部
- (void)showLabelText:(NSNotification *)notification
{
    //第三,实现通知中心内部的方法,并实现传值
    id text = notification.object;
    //赋值到文本上面
    self.textStrng.text = text;
}
//释放通知 ---第四部
- (void)dealloc
{
    //第四步,消息发送完,要移除掉
    [[NSNotificationCenter defaultCenter]removeObserver:self name:@"labelTextNotification" object:nil];
}




#pragma mark -//点击通知跳转
- (IBAction)notificationClick:(UIButton *)sender{
    
    SHTwoViewController *twoVC =[[SHTwoViewController alloc] init];
    [self presentViewController:twoVC animated:YES completion:nil];;
}







@end
